/*
 * RoboEye - Web client for www.newocr.com that allows you
 * to recognize an image captured by the camera.
 *
 * Copyright (C) Oxygen Development, 2011
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package com.devoxy.roboeye.global.log;

import com.devoxy.roboeye.R;
import com.devoxy.roboeye.global.ContextHolder;

/**
 * Created by Oxygen Development.
 * Author: Dmitriy Tarasov (dm.vl.tarasov@gmail.com)
 * Date: 24.07.11
 * Time: 11:47
 */
public final class Log {

    private static final int LOGGING_DISABLED = 0;

    private Log() {
        // disable instantiating
    }

    public static int v(String tag, String msg) {
        return isLoggingEnabled() ? android.util.Log.v(tag, msg) : LOGGING_DISABLED;
    }

    public static int v(String tag, String msg, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.v(tag, msg, tr) : LOGGING_DISABLED;
    }

    public static int d(String tag, String msg) {
        return isLoggingEnabled() ? android.util.Log.d(tag, msg) : LOGGING_DISABLED;
    }

    public static int d(String tag, String msg, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.d(tag, msg, tr) : LOGGING_DISABLED;
    }

    public static int i(String tag, String msg) {
        return isLoggingEnabled() ? android.util.Log.i(tag, msg) : LOGGING_DISABLED;
    }

    public static int i(String tag, String msg, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.i(tag, msg, tr) : LOGGING_DISABLED;
    }

    public static int w(String tag, String msg) {
        return isLoggingEnabled() ? android.util.Log.w(tag, msg) : LOGGING_DISABLED;
    }

    public static int w(String tag, String msg, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.w(tag, msg, tr) : LOGGING_DISABLED;
    }

    public static int w(String tag, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.w(tag, tr) : LOGGING_DISABLED;
    }

    public static int e(String tag, String msg) {
        return isLoggingEnabled() ? android.util.Log.e(tag, msg) : LOGGING_DISABLED;
    }

    public static int e(String tag, String msg, Throwable tr) {
        return isLoggingEnabled() ? android.util.Log.w(tag, msg, tr) : LOGGING_DISABLED;
    }

    private static boolean isLoggingEnabled() {
        return ContextHolder.getInstance().getContext().getResources().getBoolean(R.bool.debug);
    }

}
